package org.dolphin.service.base;

import java.util.Collection;
import java.util.Locale;
import org.dolphin.service.base.CustomUserDetails;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.util.Assert;

public class CustomUser extends User implements CustomUserDetails {
  private static final long serialVersionUID = 6580683497318353253L;
  private Locale locale;
  private String id;
  private String fullname;

  public CustomUser(String id, String fullname, String username, String password, boolean enabled,
      boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,
      Collection<? extends GrantedAuthority> authorities, Locale locale) {
    super(username, password, authorities);
    setIdentity(id);
    setFullname(fullname);
    setLocale(locale);
  }

  public String getFullname() {
    return fullname;
  }

  @Override
  public String getIdentity() {
    return id;
  }

  @Override
  public Locale getLocale() {
    return locale;
  }

  public void setFullname(String fullname) {
    this.fullname = fullname;
  }

  @Override
  public void setIdentity(String id) {
    this.id = id;
  }

  @Override
  public void setLocale(Locale locale) {
    Assert.notNull(locale, "Locale is mandatory");
    this.locale = locale;
  }
}
